package com.exam.system.controller;

import com.exam.system.entity.ExamMenu;
import com.exam.system.entity.ExamUser;
import com.exam.system.entity.ResponseEntity;
import com.exam.system.service.ExamMenuService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ExamMenuController
 * @Description 菜单的controller
 * @Author ckl
 * @DATE 2021/5/31 9:28
 * @versions 1.0
 */
@RestController
@CrossOrigin
public class ExamMenuController {
    @Autowired
    private ExamMenuService examMenuService;

    @RequestMapping("menu/findMenuByRoleId/{roleId}")
    public ResponseEntity<?> findMenuByRoleId(@PathVariable Integer roleId) {
        return new ResponseEntity<>(200, "获取数据成功", examMenuService.findMenuByRoleId(roleId));
    }

    @RequestMapping("menu/findAllMenu")
    public ResponseEntity<?> findAllMenu() {
        return new ResponseEntity<>(200, "获取数据成功", examMenuService.findAllMenuId());
    }
    @RequestMapping("menu/insertOneMenu")
    public ResponseEntity<ExamMenu> insertOneMenu(@RequestBody ExamMenu examMenu)  {
        return new ResponseEntity<>(200, "获取数据成功", examMenuService.insertOneMenu(examMenu));
    }
    @RequestMapping("menu/insertTwoMenu")
    public ResponseEntity<ExamMenu> insertTwoMenu(@RequestBody ExamMenu examMenu)  {
        return new ResponseEntity<>(200, "获取数据成功", examMenuService.insertTwoMenu(examMenu));
    }

    @ApiImplicitParam(name = "ExamMenu", value = "菜单实体类")
    @ApiOperation(value = "修改菜单状态")
    @RequestMapping("/menu/menustatus")
    public ResponseEntity<ExamMenu> updateStatus(@RequestBody ExamMenu examMenu) {
        examMenuService.updateById(examMenu);
        System.out.println(examMenu);
        return new ResponseEntity<>(200, "修改成功", null);

    }
    @ApiImplicitParam(name = "ExamMenu", value = "菜单实体类")
    @ApiOperation(value = "修改信息")
    @PostMapping("/menu/updatemenu")
    public ResponseEntity<ExamMenu> updateMenu(@RequestBody ExamMenu examMenu) {
        examMenuService.updateById(examMenu);
        System.out.println(examMenu);
        return new ResponseEntity<>(200, "修改成功", null);
    }

    @ApiImplicitParam(name = "ExamMenu", value = "菜单实体类")
    @ApiOperation(value = "删除菜单")
    @RequestMapping("/menu/deletemenu")
    public ResponseEntity<ExamMenu> deleteMenu(Integer id) {
        examMenuService.deleteById(id);
        System.out.println(id);
        return new ResponseEntity<>(200, "修改成功", null);
    }
}
